import csv
from bs4 import BeautifulSoup
f = open("a.html","r",encoding='utf-8')
html = f.read()

soup = BeautifulSoup(html, 'html.parser', from_encoding='gbk')
data = soup.find_all("table",class_='VirusTable_1-54-1_3U6wJT VirusTable_1-54-1_s83y8p')

tr_find = data[0].find_all('tr',class_= 'VirusTable_1-54-1_2AH4U9')

td_find_list = []
for i in tr_find:
    td_find_list1 =[]
    td_find=i.find_all('td', )
    for j in td_find:

        td_find_list1.append(j.text)
    td_find_list.append(td_find_list1)

f = open('result.csv','w',encoding='utf-8',newline='')
csv_writer = csv.writer(f)

csv_writer.writerow(["地区","新增","累计",'治愈','死亡'])
for i in td_find_list:
    csv_writer.writerow(i)

f.close()

